package net.lab1024.sa.user.module.business.course.controller;

import net.lab1024.sa.common.common.domain.ValidateList;
import net.lab1024.sa.user.constant.UserSwaggerTagConst;
import net.lab1024.sa.user.module.business.course.domain.form.StudentAddForm;
import net.lab1024.sa.user.module.business.course.domain.form.StudentQueryForm;
import net.lab1024.sa.user.module.business.course.domain.form.StudentUpdateForm;
import net.lab1024.sa.user.module.business.course.domain.vo.StudentVO;
import net.lab1024.sa.user.module.business.course.service.StudentService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.common.common.domain.ResponseDTO;
import net.lab1024.sa.common.common.domain.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;

/**
 * 学员 Controller
 *
 * @Author jabari
 * @Date 2023-08-05 17:22:36
 * @Copyright 51dev.cn
 */

@RestController
@Api(tags = UserSwaggerTagConst.Business.COURSE)
public class StudentController {

    @Autowired
    private StudentService studentService;

    @ApiOperation("分页查询 @author jabari")
    @PostMapping("/student/queryPage")
    public ResponseDTO<PageResult<StudentVO>> queryPage(@RequestBody @Valid StudentQueryForm queryForm) {
        return ResponseDTO.ok(studentService.queryPage(queryForm));
    }

    @ApiOperation("添加 @author jabari")
    @PostMapping("/student/add")
    public ResponseDTO<String> add(@RequestBody @Valid StudentAddForm addForm) {
        return studentService.add(addForm);
    }

    @ApiOperation("更新 @author jabari")
    @PostMapping("/student/update")
    public ResponseDTO<String> update(@RequestBody @Valid StudentUpdateForm updateForm) {
        return studentService.update(updateForm);
    }

    @ApiOperation("批量删除 @author jabari")
    @PostMapping("/student/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return studentService.batchDelete(idList);
    }

    @ApiOperation("单个删除 @author jabari")
    @GetMapping("/student/delete/{studentId}")
    public ResponseDTO<String> batchDelete(@PathVariable Integer studentId) {
        return studentService.delete(studentId);
    }
}
